package com.inepex.graphicstests.client.govscanvasperf;


import com.google.gwt.user.client.ui.Composite;
import com.inepex.graphicstests.client.misc.Globals;
import com.inepex.graphicstests.client.misc.GraphicalObjectFactory;
import com.inepex.inegraphics.impl.client.canvas.CanvasWidget;

public class IneCanvasDirectUsage extends Composite implements Runnable{
	
	CanvasWidget canvas;
	
	
	public IneCanvasDirectUsage() {
		init();
	}
	
	private void init(){
		canvas = new CanvasWidget(Globals.width, Globals.height);
		initWidget(canvas);
	}

	@Override
	public int doUpdate() {
		fillUpWithShapes();
		return Globals.goCount;
	}
	
	
	private void fillUpWithShapes(){
		canvas.setFillStyle("white");
		canvas.fillRect(0, 0, Globals.width, Globals.height);
		canvas.scale(0.5, 1);
//		canvas.setWidth(Globals.width);
//		canvas.setHeight(Globals.height);
		for(int i=0; i<Globals.goCount; i++){
			GraphicalObjectFactory.generateRandomShapeOnCanvas(canvas);
		}
	}
	
	private void start(){
		Main.getRunner().run(this);
	}

	
	@Override
	protected void onLoad() {
		start();
	}

}
